package com.farm.web.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.log4j.Logger;

import com.farm.core.auth.domain.LoginUser;
import com.farm.parameter.FarmParameterService;
import com.farm.wcp.util.ThemesUtil;
import com.farm.web.constant.FarmConstant;

/**
 * 判读是否移动端浏览器，并按条件展示数据
 * 
 * @author macpl
 *
 */
public class IfMobileTaget extends TagSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	static final Logger log = Logger.getLogger(IfMobileTaget.class);

	/**
	 * 状态，true或false是展示内容
	 */
	private String state;

	@Override
	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}

	@Override
	public int doStartTag() throws JspException {
		HttpServletRequest request = (HttpServletRequest) super.pageContext.getRequest();
		// 显示
		if (ThemesUtil.isMobile(request) == state.toUpperCase().equals("TRUE")) {
			return EVAL_BODY_INCLUDE;
		}
		return SKIP_BODY;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

}
